package com.lidong.zc.databasemodel.init.core;

import com.lidong.zc.databasemodel.entity.database.DataBaseTable;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 9/21/2022 9:13 PM
 */
public abstract class AbstractCreateTableManage extends CreateTableManage {

    protected AbstractCreateTableManage(InitDataBaseContext initDataBaseContext) {
        super(initDataBaseContext);
    }

    /**
     * 获取表
     *
     * @return List
     * @throws SQLException SQLException
     */
    protected abstract List<DataBaseTable> getDataBaseTableList() throws SQLException;

    /**
     * 获取字段信息
     *
     * @param dataBaseTableList 元数据表
     * @throws SQLException SQLException
     */
    protected abstract void getColumnList(List<? extends DataBaseTable> dataBaseTableList) throws SQLException;

    /**
     * 获取元数据索引信息
     *
     * @param dataBaseTableList 元数据表
     * @throws SQLException SQLException
     */
    protected abstract void getIndexList(List<? extends DataBaseTable> dataBaseTableList) throws SQLException;

    /**
     * 获取连接
     *
     * @return connection
     */
    public Connection getConnection() {
        return this.getInitDataBaseContext().getDruidPooledConnection().getConnection();
    }


}
